/* 
 * Project: FlarDetector
 *
 * Copyright 2009, Longfellow Chen
 * --------------------------------------------------------------------------------
 * This work complements FLARToolkit, developed by Saqoosha as part of the Libspark project.
 *	http://www.libspark.org/wiki/saqoosha/FLARToolKit
 * FLARToolkit is Copyright (C)2008 Saqoosha,
 * and is ported from NYARToolkit, which is ported from ARToolkit.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this framework; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 * 
 * For further information please contact:
 *	<fellong0307@gmail.com>
 *	http://fellong.blogspot.com/
 * 
 */
 
 package com.fellong.flash.flar.util
{
	import flash.media.Camera;
	import flash.media.Video;

	public class FlarCapture extends FlarCaptureSource
	{			
		private var _video:Video;
		
		public function FlarCapture( _width:int = 320, _height:int = 240, cname:String=null )
		{
			super( _width, _height );
			
			var n1:Array = Camera.names;
			
			var _webcam:Camera = Camera.getCamera( cname );
			if (!_webcam) {
				throw new Error('No webcam!!!!');
			}
			_webcam.setMode(_width, _height, 30);
			
			_video = new Video(_width, _height);
			_video.attachCamera(_webcam);
		}
		
		override public function draw():void
		{
			this.bitmapData.draw(_video);
		}

	}
}